/**
 * 
 */
package sk.lukaskrupa.guess.the.color.listeners;

import sk.lukaskrupa.guess.the.color.logging.Logging;
import sk.lukaskrupa.guess.the.color.ui.R;
import sk.lukaskrupa.guess.the.color.ui.Settings;
import android.view.View;
import android.view.View.OnClickListener;

/**
 * Listen to Settings activity buttons.
 * 
 * @author Lukas Krupa (lukas0krupa@gmail.com)
 * 
 */
public class SettingsButtonListener implements OnClickListener {

	private static final Logging logger = Logging.getLog(SettingsButtonListener.class);

	private final Settings settings;

	/**
	 * Constructs listener and save reference to Menu activity.
	 * 
	 * @param menu
	 *            to be used for closeing
	 */
	public SettingsButtonListener(Settings settings) {
		this.settings = settings;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void onClick(View v) {

		logger.debug("onClick", "You clicked on button with ID=" + v.getId());
		if (v.getId() == R.id.saveSettings) {

			logger.info("onClick", "Saving settings and exiting.");
			this.settings.saveAndExit();

		} else if (v.getId() == R.id.backSettings) {

			logger.info("onClick", "Exiting settings, without saving.");
			this.settings.exit();
		}
	}
}
